package org.example.innovate.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.innovate.common.CommonResponse;
import org.example.innovate.domain.Comment;
import org.example.innovate.service.CommentService;
import org.example.innovate.vo.CommentVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/comment")
@Valid
public class CommentController {
    @Resource
    private CommentService commentService;
    @PostMapping("/add")
    public CommonResponse<CommentVo> addComment(@Valid @RequestBody Comment comment, HttpServletRequest request) {
        return commentService.addComment(comment,request);
    }
    @PostMapping("/delete")
    public CommonResponse<Comment> deleteComment(@Valid @RequestBody Comment comment) {
        return commentService.deleteComment(comment);
    }
}
